﻿using System.Xml.Linq;
using Maple.Weixin.MP.Helpers;

namespace Maple.Weixin.MP.Entities.Messages
{
    public sealed class RequestMessageLocation : RequestMessageBase
    {
        public override RequestMessageType MsgType
        {
            get { return RequestMessageType.Location; }
        }

        /// <summary>
        /// 地理位置纬度
        /// </summary>
        public double Location_X { get; private set; }
        /// <summary>
        /// 地理位置经度
        /// </summary>
        public double Location_Y { get; private set; }
        public int Scale { get; private set; }
        public string Label { get; private set; }

        protected override void FillPropertiesByXml(XDocument document)
        {
            base.FillPropertiesByXml(document);
            this.Location_X = double.Parse(document.GetElementValue("Location_X", true));
            this.Location_Y = double.Parse(document.GetElementValue("Location_Y", true));
            this.Scale = int.Parse(document.GetElementValue("Scale", true));
            this.Label = document.GetElementValue("Label", true);
        }

        public override T Accept<T>(RequestMessageVisitor<T> visitor) {
            return visitor == null ? default(T) : visitor.Visit(this);
        }
    }
}
